package com.cet.designapplication.bridge.abst;

import com.cet.designapplication.bridge.function.RegisterLoginFuncInterface;
import com.cet.designapplication.pojo.UserInfo;
import com.cet.designapplication.repo.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.io.PipedReader;

/**
 * @author NSOC
 */

public abstract class AbstractRegisterLoginComponent {

    protected RegisterLoginFuncInterface registerLoginFuncInterface;

    public AbstractRegisterLoginComponent(RegisterLoginFuncInterface registerLoginFuncInterface) {
        validate(registerLoginFuncInterface);
        this.registerLoginFuncInterface = registerLoginFuncInterface;
    }

    private void validate(RegisterLoginFuncInterface registerLoginFuncInterface) {
        if (registerLoginFuncInterface == null) {
            throw new RuntimeException("funcInterface is null!");
        }
    }

    public abstract String login(String username, String password);

    public abstract String register(UserInfo userInfo);

    public abstract boolean checkUserExists(String userName);

    public abstract String login3rd(HttpServletRequest request);
}
